<template>
	<view class="columnbox wdh-100 content" v-if="user">
		<view class="status-box rowbox wdh-100">
			<view class="status-w" v-if="wenzhenpay.status==2">问诊中</view>
			<view class="status-w" v-else-if="wenzhenpay.status==3">已退款</view>
			<view class="status-w" v-else-if="wenzhenpay.status==4">问诊结束</view>
		</view>
		<view class="columnbox u-box">
			<view class="u-title">患者详情</view>
			<view class="rowbox one-info jus">
				<view class="info-title">患者资料</view>
				<view>{{user.name}} {{user.sex==2?'女':'男'}} | {{user.age}}岁</view>
			</view>
			<view class="rowbox one-info jus">
				<view class="info-title">病情描述</view>
				<view v-if="message">{{JSON.parse(message.content).content}}</view>
			</view>
			<view class="rowbox one-info jus">
				<view class="info-title">既往史</view>
				<view class="columnbox als">
					<view> {{bingshi.text}}</view>
					<view class="img-list">
						<image v-for="(item,index) in bingshi.img" :key='index' @click="previewImg('jws',item)"
							:src="item" mode="aspectFill"></image>
					</view>
				</view>
			</view>
			<!-- <view class="rowbox one-info jus">
				<view class="info-title">现病史</view>
				<view>{{JSON.parse(user.bingshi).text}}</view>
			</view> -->
			<view class="rowbox one-info jus">
				<view class="info-title">过敏史</view>
				<view class="columnbox als">
					<view> {{guomin.text}}</view>
					<view class="img-list">
						<image v-for="(item,index) in guomin.img" :key='index' @click="previewImg('gms',item)"
							:src="item" mode="aspectFill"></image>
					</view>
				</view>
			</view>
			<!-- <view class="rowbox one-info jus">
				<view class="info-title">肝肾功能</view>
				<view>{{JSON.parse(message.content).ganshen==1?'正常':'异常'}}</view>
			</view> -->
		</view>
		<view style="width: 100%;height: 200rpx;"></view>
		<view class="rowbox wdh-100 bottom-box">
			<view class="rowbox wdh-100 send-btn" @click="showChat">查看交流</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: 0,
				user: null,
				message: null,
				wenzhenpay: null,
				bingshi: {
					text: '',
					img: []
				},
				guomin: {
					text: '',
					img: []
				}
			}
		},
		onLoad(options) {
			this.id = options.id * 1
			this.getDetail()
		},
		methods: {
			previewImg(type, img) {
				uni.previewImage({
					urls: type == 'jws' ? this.bingshi.img : this.guomin.img,
					current: img
				})
			},
			getDetail() {
				this.$req.post('/doctor/wenzhenjlinfo', {
					id: this.id
				}).then(res => {
					this.user = res.data.data.user
					this.message = res.data.data.message
					this.wenzhenpay = res.data.data.wenzhenpay
					let guomin = JSON.parse(res.data.data.user.guomin)
					this.guomin = {
						text: guomin.text,
						img: guomin.img == '' ? [] : guomin.img.split(',')
					}
					let bingshi = JSON.parse(res.data.data.user.bingshi)
					this.bingshi = {
						text: bingshi.text,
						img: bingshi.img == '' ? [] : bingshi.img.split(',')
					}
				})
			},
			showChat() {
				uni.navigateTo({
					url: '/pages/chat/detail?id=' + this.user.memberid
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		min-height: 100vh;
		background: #F5F8FB;
		justify-content: flex-start;
	}

	.status-box {
		color: #fff;
		height: 400rpx;
		align-items: flex-start;
		justify-content: flex-start;
		padding: 32rpx 32rpx;
		font-size: 36rpx;
		background: linear-gradient(to bottom, #00b6b2, #F5F8FB);
	}

	.u-box {
		width: 710rpx;
		background: #fff;
		border-radius: 20rpx;
		padding: 20rpx 20rpx;
		margin-top: -270rpx;
	}

	.u-title {
		width: 100%;
		font-size: 32rpx;
		margin-bottom: 20rpx;
		font-weight: bold;
	}

	.one-info {
		width: 100%;
		padding: 32rpx 0;
		background: #fff;
		font-size: 26rpx;

		.info-title {
			// font-weight: bold;
			font-size: 26rpx;
			// color: #202020;
			width: 120rpx;
			margin-right: 20rpx;
			color: #9b9b9b;
		}

		.info-input {
			width: calc(100% - 190rpx);
			text-align: left;
			font-size: 26rpx;
		}

		.code-box {
			width: calc(100% - 190rpx);
		}

		.code-input {
			text-align: left;
			font-size: 26rpx;
			width: 200rpx;
		}

		.code-btn {
			font-weight: bold;
		}
	}

	.img-list {
		display: flex;
		flex-wrap: wrap;
		justify-content: flex-start;

		image {
			width: 100rpx;
			height: 100rpx;
			border-radius: 10rpx;
			margin-top: 10rpx;
			margin-right: 20rpx;
			border: #f5f3f5 solid 1px;
		}
	}
</style>